<template>
	<web-view :src="webViewURL"></web-view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { useUserStore } from '@/store/userStore.js';

const userStore = useUserStore();

const webViewURL = ref('');

onLoad((option) => {
	console.log('option', option);
	let url = decodeURIComponent(option.url);

	console.log('解码后的H5url路径：', url);

	if (url.includes('?')) {
		let subStr = `&token=${userStore.access_token}&key=${userStore.UserAccessInfo.encryptKey}&miniProgram=true`;
		url = url + subStr;
	} else {
		let subStr = `?token=${userStore.access_token}&key=${userStore.UserAccessInfo.encryptKey}&miniProgram=true`;
		url = url + subStr;
	}
	
	console.log('带上用户信息的URL：', url);
	
	webViewURL.value = url;
});
</script>

<style lang="scss"></style>
